package com.hoshiicloud.mallshop.feign;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hoshiicloud.common.query.OmnipotentParam;
import com.hoshiicloud.common.query.OmnipotentWrapper;
import com.hoshiicloud.common.rpc.Response;
import com.hoshiicloud.goods.entity.goods.Gallery;
import com.hoshiicloud.goods.entity.goods.GoodsCategory;
import com.hoshiicloud.goods.entity.goods.GoodsGallery;
import com.hoshiicloud.goods.entity.sku.*;
import com.hoshiicloud.goods.entity.spu.BaseGoodsGallery;
import com.hoshiicloud.goods.entity.spu.BaseSpu;
import com.hoshiicloud.goods.entity.spu.ExtSpu;
import com.hoshiicloud.goods.param.ListSkuSpuParam;
import com.hoshiicloud.goods.param.sku.*;
import com.hoshiicloud.goods.param.spu.BaseSpuAddParam;
import com.hoshiicloud.goods.param.spu.BaseSpuUpdateParam;
import com.hoshiicloud.goods.param.spu.ExtSpuAddParam;
import com.hoshiicloud.goods.param.spu.ExtSpuUpdateParam;
import com.hoshiicloud.goods.vo.BranchStoreGoodsVo;
import com.hoshiicloud.goods.vo.GoodsPropertiesVo;
import com.hoshiicloud.goods.vo.ListSpuSkuVo;
import com.hoshiicloud.goods.vo.sku.BaseSkuVo;
import com.hoshiicloud.mallshop.feign.hystrix.ShopGoodsSpuSkuFeignServiceFallback;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;
import java.util.Map;

/**
 *  2019/8/7 18:14 qry
 *   goods 域   product-manage  / ext-sku  /ext-spu
 */
@FeignClient(name = "hoshiicloud-goods", fallback = ShopGoodsSpuSkuFeignServiceFallback.class)
public interface ShopGoodsSpuSkuFeignService {


    // ----------------------------------------↓base-spu↓------------------------------------

    /**
     *  保存baseSpu并返回的  BaseSpu 对象
     * @param param BaseSpuAddParam
     * @return BaseSpu
     */
    @PostMapping("/goods/base-spu/saveBaseSpu")
    Response<BaseSpu> saveBaseSpu(@RequestBody BaseSpuAddParam param);

    /**
     *  根据Id更新BaseSpu信息
     * @param param 更新内容
     * @return true or false
     */
    @PutMapping("/goods/base-spu/update")
    Response<Boolean> updateBaseSpu(@RequestBody BaseSpuUpdateParam param);

    /**
     *  批量更新baseSpu信息
     * @param param 更新条件以及更新内容
     * @return true or false
     */
    @PostMapping("/goods/base-spu/updateBatch")
    Response<Boolean> updateBaseSpuBatch(@RequestBody OmnipotentParam<BaseSpu> param);

    // ----------------------------------------↑base-spu↑------------------------------------

    // ----------------------------------------↓product-manage↓------------------------------------
    /**
     *  qry
     *  根据店铺Id和 extSkuId 查询 ProductManage信息
     */
    @GetMapping(value = "/goods/product-manage/getOneByStoreIdAndSkuId")
    Response<ProductManage> getProductManageOneByStoreIdAndSkuId(@RequestParam("map") Map<String, Object> map);

    /**
     *  更新商品sku分配
     */
    @PutMapping(value = "/goods/product-manage/update")
    Response updateProductMangerById(@RequestBody ProductManageUpdateParam param);

    /**
     * 根据条件获取 product-manage 列表
     */
    @GetMapping("/goods/product-manage/query/list")
    Response<List<ProductManage>> listProductManageByParam(@RequestBody ProductManageQueryParam param);

    /**
     *  批量保存product_manage qry
     */
    @PostMapping("/goods/product-manage/saveBatch")
    Response<Boolean> saveProductManageBatch(@RequestBody List<ProductManage> allProductManage);

    /**
     * 查询分店下的商品列表 qry
     */
    @PostMapping(value = "/goods/product-manage/listBranchStoreGoods")
    Response<Page<BranchStoreGoodsVo>> listBranchStoreGoods(@RequestBody BranchStoreProductPageParam param);

    /**
     *  保存 productManage qry
     */
    @PostMapping(value = "/goods/product-manage/save")
    Response<Boolean> saveProductManage(@RequestBody ProductManageAddParam param);

    /**
     *  根据id删除productManage信息
     */
    @DeleteMapping(value = "/goods/product-manage/delete/{id}")
    Response<Boolean> deleteProductManger(@PathVariable("id") Long id);

    /**
     *  批量更新商品管理信息
     * @param param 更新条件以及更新值
     * @return true or false
     */
    @PostMapping(value = "/goods/product-manage/updateBatch")
    Response<Boolean> updateProductMange(@RequestBody OmnipotentParam<ProductManage> param);

    // ----------------------------------------↑product-manage↑------------------------------------








    // ----------------------------------------↓ext-sku↓------------------------------------
    /**
     * 获取每个店铺分配的商品数量
     * qry
     */
    @GetMapping(value = "/goods/ext-sku/getStoreSkuNum")
    Response<Map<String,String>> getStoreSkuNum(@RequestParam("storeIds") List<Long> storeIds);


    /**
     * qry
     * 根据 店铺id 获取 各店铺对应base_sku_ids
     */
    @GetMapping("/goods/ext-sku/queryStoresAndBaseSkuIds")
    Response<Map<String, List<String>>> queryExtskuAndBaseSkuIds(@RequestParam("storeIds") List<Long> storeIds);

    /**
     * 15:27 2019/8/12 qry
     *  1.storesys- 分店商品-分配商品-子店同步总店商品-获取总店的 所有ext-sku信息
     **/
    @GetMapping("/goods/ext-sku/listByParam}")
    Response<List<ExtSku>> listExtSkuByParam(@RequestBody ExtSkuQueryParam param);

    /**
     * 批量新增 ext_sku qry
     */
    @PostMapping("/goods/ext-sku/saveBatch")
    Response<Boolean> saveExtSkuBatch(@RequestBody List<ExtSku> allExtSku);


    /**
     * 根据店铺ID 跟 skuId 获取 ext_sku   qry
     */
    @GetMapping(value = "/goods/ext-sku/getOneByStoreIdAndSkuId")
    Response<ExtSku> getExtSkuOneByStoreIdAndSkuId(@RequestParam("map") Map<String, Object> map);

    /**
     * 保存ext-sku 返回 ExtSku实体 qry
     */
    @PostMapping(value = "/goods/ext-sku/saveExtSku")
    Response<ExtSku> saveExtSku(@RequestBody ExtSkuAddParam param);

    /**
     * 修改扩展商品SKU
     */
    @PutMapping(value = "/goods/ext-sku/update")
    Response extSkuUpdate(@RequestBody ExtSkuUpdateParam param);

    /**
     *  通过Id删除ExtSku信息
     */
    @DeleteMapping(value = "/goods/ext-sku/delete/{id}")
    Response<Boolean> deleteExtSku(@PathVariable("id") Long id);

    /**
     *  批量更新ExtSpu信息
     * @param param 更新条件以及更新的内容
     * @return true or false
     */
    @PostMapping(value = "/goods/ext-sku/updateBatch")
    Response<Boolean> updateExtSkuBatch(@RequestBody OmnipotentParam<ExtSku> param);

    /**
     *  批量查询 ExtSku
     * @param params 查询条件
     * @return List<ExtSku>
     */
    @PostMapping(value = "/goods/ext-sku/queryBatch")
    Response<List<ExtSku>> listExtSku(@RequestBody List<OmnipotentWrapper> params);

    /**
     *  获取分店可添加的拓展 sku分页列表
     */
    @GetMapping(value = "/goods/extsku/getBranchStoreCanAddSkuPage")
    Response<Page<ListSpuSkuVo>> getBranchStoreCanAddSkuPage(@RequestBody ListSkuSpuParam param);

    // ----------------------------------------↑ext-sku↑------------------------------------



    // ----------------------------------------↓ext-spu↓------------------------------------
    /**
     * 根据Id查询ExtSpu信息
     */
    @GetMapping("/goods/ext-spu/{id}")
    Response<ExtSpu> getExtSpuById(@PathVariable("id") Long id);

    /**
     * 1.storesys- 分店商品-分配商品-子店同步总店商品-获取总店的 所有ext-spu信息 qry
     */
    @GetMapping("/goods/ext-spu/listByStoreId/{storeId}")
    Response<List<ExtSpu>> listExtSpuByStoreId(@PathVariable("storeId") Long storeId);

    /**
     * 批量新增 ext_spu    qry
     */
    @PostMapping("/goods/ext-spu/saveBatch")
    Response<Boolean> saveExtSpuBatch(@RequestBody  List<ExtSpu> allExtSpu);


    /**
     * 根据店铺ID 跟 spuID 获取 ext_spu  qry
     */
    @GetMapping(value = "/goods/ext-spu/getOneByStoreIdAndSpuId")
    Response<ExtSpu> getExtSpuOneByStoreIdAndSpuId(@RequestParam("map") Map<String, Object> map);

    /**
     *  保存extSpu 返回ExtSpu的实体 qry
     */
    @PostMapping(value = "/goods/ext-spu/saveExtSpu")
    Response<ExtSpu> saveExtSpu(@RequestBody ExtSpuAddParam param);


    /**
     *  自定义条件批量查询 ExtSpu
     */
    @PostMapping(value = "/goods/ext-spu/omnipotentQuery")
    Response<List<ExtSpu>> queryOmnipotentExtSpu(@RequestBody List<OmnipotentWrapper> wrappers);

    /**
     *  更新扩展Spu
     */
    @PutMapping(value = "/goods/ext-spu/update")
    Response<Boolean> extSpuUpdate(@RequestBody ExtSpuUpdateParam param);

    /**
     *  通过Id删除扩展Spu
     */
    @DeleteMapping(value = "/goods/ext-spu/delete/{id}")
    Response<Boolean> deleteExtSpu(@PathVariable("id") Long id);

    /**
     *  获得该店铺下商品权重的最大值
     * @param storeId 店铺Id
     * @return 权重最大值
     */
    @GetMapping(value = "/goods/ext-spu/getMaxWeight")
    Response<Long> getExtSpuMaxWeight(@RequestParam("storeId") Long storeId);

    /**
     *  批量更新ExtSpu
     * @param param 更新条件和内容
     * @return true  or  false
     */
    @PostMapping(value = "/goods/ext-spu/updateBatch")
    Response<Boolean> updateExtSpuBatch(@RequestBody OmnipotentParam<ExtSpu> param);

    /**
     *  通过 extSkuId 的集合查询 ExtSku信息 TODO:HERE
     * @param ids extSkuId  集合
     * @return List<ExtSpu>
     */
    @GetMapping(value = "/goods/ext-spu/getByIds")
    Response<List<ExtSpu>> listExtSpuByIds(@RequestParam("ids") List<Long> ids);

    // ----------------------------------------↑ext-spu↑------------------------------------



    // ----------------------------------------↓base-sku↓------------------------------------

    /**
     * 16:09 2019/9/10 qry
     **/
    @PostMapping("/goods/base-sku/listByParam")
    Response<List<BaseSkuVo>> listBaseSkuByParam(@RequestBody SkuBaseListParam param);


    /**
     *  保存BaseSku信息, 并返回保存的 BaseSku对象
     * @param param BaseSkuAddParam
     * @return BaseSku
     */
    @PostMapping("/goods/base-sku/saveBaseSku")
    Response<BaseSku> saveBaseSku(@RequestBody BaseSkuAddParam param);

    /**
     *  批量更新BaseSku
     * @param param 更新条件以及更新值
     * @return true or false
     */
    @PostMapping("/goods/base-sku/updateBatch")
    Response<Boolean> updateBaseSkuBatch(@RequestBody OmnipotentParam<BaseSku> param);

    /**
     *  批量查询baseSku
     * @param params 查询条件
     * @return List<BaseSku>
     */
    @PostMapping("/goods/base-sku/queryBatch")
    Response<List<BaseSku>> listBaseSku(@RequestBody List<OmnipotentWrapper> params);

    /**
     *  通过Id 更新BaseSku信息
     * @param param 更新值
     * @return true or false
     */
    @PutMapping("/goods/base-sku/update")
    Response<Boolean> baseSkuUpdate(@RequestBody BaseSkuUpdateParam param);

    // ----------------------------------------↑base-sku↑------------------------------------




    // ----------------------------------------↓public-properties↓------------------------------------

    /**
     *  获取销售单位和包装单位
     * @param companyId 租户Id
     * @param propertyName 公共属性名称， 如果是要查包装单位就传 “包装单位”， 如果是查“销售单位”传 “销售单位”
     * @return 包装单位和销售单位的集合
     */
    @GetMapping("/goods/public-properties/dropdownBox")
    Response<List<String>> dropdownBox(@RequestParam("companyId")  Long companyId, @RequestParam("propertyName") String propertyName);

    // ----------------------------------------↑public-properties↑------------------------------------


    // ----------------------------------------↓goods-properties↓------------------------------------

    /**
     *  获取指定类目下的属性信息
     * @param categoryId 类目Id
     * @param companyId 租户Id
     * @return 类目下属性信息的集合
     */
    @GetMapping("/goods/goods-properties/getProperByCateId")
    Response<List<GoodsPropertiesVo>> getProperByCateId(@RequestParam("categoryId") Long categoryId, @RequestParam("companyId") Long companyId);

    // ----------------------------------------↑goods-properties↑------------------------------------



    // ----------------------------------------↓goods-brand↓------------------------------------

    /**
     *  查询指定类目下的品牌信息
     * @param cateId 类目Id
     * @return  品牌信息
     */
    @GetMapping("/goods/goods-brand/getBrandCategoryByCateId")
    Response<List<Map<String, Object>>> getGoodsBrandsByCateId(@RequestParam("cateId") Long cateId);


    // ----------------------------------------↑goods-brand↑------------------------------------


    // ----------------------------------------↓goods-category↓------------------------------------

    /**
     *  根据三级类目id查询类目名称
     * @param categoryContextQueryStr 类目Id串
     * @return 类目名称以 > 的形式分隔
     */
    @GetMapping("/goods/goods-category/getCategoryContext")
    Response<String> getCategoryContext(@RequestParam("categoryContextQueryStr") String categoryContextQueryStr);

    /**
     *  通过Id查询类目名称
     * @param id 类目Id
     * @return  GoodsCategory
     */
    @GetMapping("/goods/goods-category/{id}")
    Response<GoodsCategory> getGoodsCategoryById(@PathVariable("id") Long id);

    // ----------------------------------------↑goods-category↑------------------------------------

    // ----------------------------------------↓gallery↓------------------------------------

    /**
     * 批量保存相册信息
     * @param galleries 需要保存的相册数据
     * @return true or false
     * */
    @PostMapping("/gallery/gallery/saveBatch")
    Response<Boolean> saveGalleryBath(@RequestBody List<Gallery> galleries);

    /**
     * 批量更新相册信息
     * @param param 更新条件以及更新值
     * @return true or false
     */
    @PostMapping("/gallery/gallery/updateBatch")
    Response<Boolean> updateGalleryBatch(@RequestBody OmnipotentParam<Gallery> param);

    // ----------------------------------------↓base-goods-gallery↓------------------------------------
    /**
     * 批量保存BaseSpu与相册关联信息
     * @param baseGoodsGalleries 需要保存的关联信息
     * @return true or false
     * */
    @PostMapping("/goods/base-goods-gallery/saveBatch")
    Response<Boolean> saveBaseGoodsGalleryBatch(@RequestBody List<BaseGoodsGallery> baseGoodsGalleries);

    /**
     *  批量更新baseGoodsGallery
     * @param param 更新条件以及更新内容
     * @return true or false
     */
    @PostMapping("/goods/base-goods-gallery/updateBatch")
    Response<Boolean> updateBaseGoodsGalleryBatch(@RequestBody OmnipotentParam<BaseGoodsGallery> param);

    /**
     *  批量删除baseGoodsGallery： 物理删除
     * @param param 删除条件
     * @return true or false
     */
    @DeleteMapping("/goods/base-goods-gallery/removeBatch")
    Response<Boolean> removeBaseGoodsGalleryBatch(@RequestBody List<OmnipotentWrapper> param);
    // ----------------------------------------↓base-sku-gallery↓------------------------------------
    /**
     *  保存BaseSku的图片信息
     * @param param BaseSkuGalleryAddParam
     * @return true or false
     */
    @PostMapping("/goods/base-sku-gallery/save")
    Response<Boolean> saveBaseSkuGallery(@RequestBody BaseSkuGalleryAddParam param);

    /**
     *  批量更新基础SKU商品图片资源
     * @param param 更新条件以及更新值
     * @return true or false
     */
    @PostMapping("/goods/base-sku-gallery/updateBatch")
    Response<Boolean> updateBaseSkuGalleryBatch(@RequestBody OmnipotentParam<BaseSkuGallery> param);

    // ----------------------------------------↓base-sku-gallery↓------------------------------------

    /**
     * 保存供应商商品SKU信息
     * @param param VendorGoodsSkuAddParam
     * @return true or false
     */
    @PostMapping("/goods/vendor-goods-sku/save")
    Response<Boolean> saveVendorGoodsSku(@RequestBody VendorGoodsSkuAddParam param);

    /**
     *  批量更新供应商sku表
     * @param params 更新条件以及更新值
     * @return true or false
     */
    @PostMapping("/goods/vendor-goods-sku/updateBatch")
    Response<Boolean> updateVendorGoodsSkuBatch(@RequestBody OmnipotentParam<VendorGoodsSku> params);

    /**
     *  通过Id 更新VendorGoodsSku
     * @param param 更新值
     * @return true or false
     */
    @PutMapping("/goods/vendor-goods-sku/update")
    Response<Boolean> vendorGoodsSkuUpdate(@RequestBody VendorGoodsSkuUpdateParam param);
}

